package org.checkboo.hopefullyengine.light;

import java.nio.FloatBuffer;

import org.checkboo.hopefullyengine.sceneelements.Color;
import org.checkboo.math.Vector3f;
import org.lwjgl.BufferUtils;

public class SpotLight extends Light {

	private Vector3f position;
	private Vector3f direction;
	private float spread;
	private FloatBuffer pos;
	private FloatBuffer dir;
	
	public SpotLight(){
		super();
		this.position = new Vector3f();
		this.direction = new Vector3f();
	}
	
	public SpotLight(Color diffuse, Color specular, Color ambient, Vector3f position, Vector3f direction, float spread){
		super(diffuse, specular, ambient);
		this.position = position;
		this.direction = direction;
		this.spread = spread;
	}

	public Vector3f getPosition() {
		return position;
	}
	
	public FloatBuffer getPositionBuffer(){
		if(null == pos)
			pos = BufferUtils.createFloatBuffer(4);
		pos.put(this.position.getX()).put(this.position.getY()).put(this.position.getZ()).put(1.0f).rewind();
		return pos;
	}

	public void setPosition(Vector3f position) {
		this.position = position;
	}

	public Vector3f getDirection() {
		return direction;
	}
	
	public FloatBuffer getDirectionBuffer(){
		if(null == dir)
			dir = BufferUtils.createFloatBuffer(4);
		dir.put(this.direction.getX()).put(this.direction.getY()).put(this.direction.getZ()).put(1.0f).rewind();
		return dir;
	}

	public void setDirection(Vector3f direction) {
		this.direction = direction;
	}

	public float getSpread() {
		return spread;
	}

	public void setSpread(float spread) {
		this.spread = spread;
	}
	
	
}
